﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BAL.SysManagerBAL;
using BO;

public partial class View_SysManager_SMStartDate : System.Web.UI.Page
{
    private FiscalYear _fy;
    private WriteLog _wl;
    private SMStartDateBAL _smBal;
    private int _intResult;
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void bAccept_Click(object sender, EventArgs e)
    {
        _intResult = 0;

        // Page is valid, lets go ahead and insert records

        // Instantiate BAL object

        _smBal = new SMStartDateBAL();

        // Instantiate the object we have to deal with

        _fy = new FiscalYear();
        _wl = new WriteLog();

        // set the properties of the object

        if (dpSmStartDate.SelectedDate != null)
        {
            _fy.StartDate = (DateTime)dpSmStartDate.SelectedDate;
            _fy.RegisterId = 1;
            _wl.Ip = Request.UserHostAddress;
            _wl.JobModId = 13;
            _wl.ControlDate = DateTime.Now;
        }
        try
        {
            _intResult = _smBal.Insert(_fy,_wl);

            if (_intResult > 0)
            {
                Response.Write("<script language='javascript'>alert('Khai báo thất bại. Mời bạn khai báo lại.');</script>");
            }
            else
            {
                Response.Write("<script language='javascript'>alert('Khai báo thành công.');</script>");
            }
        }
        catch (Exception ee)
        {
            Response.Write("<script language='javascript'>alert('" + ee.Message.ToString() + ".');</script>");
        }
        finally
        {
            _fy = null;
            _smBal = null;
        }        
    }
}